package com.artPreter.controller;


import com.artPreter.pojo.Artwork;
import com.artPreter.pojo.EventExhibition;
import com.artPreter.pojo.IndexItemRelative;
import com.artPreter.pojo.Result;
import com.artPreter.service.IIndexItemRelativeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 首页板块-内容关系表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-12-10
 */
@RestController
@RequestMapping("/indexItemRelative")
public class IndexItemRelativeController {

    @Autowired
    private IIndexItemRelativeService indexItemRelativeService;

    /**
     * 首页板块分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexItemRelative indexItemRelative) {
        IPage<IndexItemRelative> indexItemRelativeIPage = indexItemRelativeService.getPage(currentPage, size, indexItemRelative);
        return Result.success(indexItemRelativeIPage);
    }

    /**
     *  添加首页板块
     * @param indexItemRelative
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody IndexItemRelative indexItemRelative) {
        indexItemRelativeService.add(indexItemRelative);
        return Result.success();
    }

    /**
     *  修改首页板块
     * @param
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody IndexItemRelative indexItemRelative) {
        indexItemRelativeService.edit(indexItemRelative);
        return Result.success();
    }

    /**
     * 删除首页板块
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody IndexItemRelative indexItemRelative){
        indexItemRelativeService.delete(indexItemRelative);
        return Result.success();
    }

    /**
     * 获取首页板块列表
     * @param
     * @return
     */
    @PostMapping("/getList")
    public Result getList(@RequestBody IndexItemRelative indexItemRelative){
        List<IndexItemRelative> result = indexItemRelativeService.getList(indexItemRelative);
        return Result.success(result);
    }

    /**
     * 获取未关联的艺术品分页
     * @param currentPage
     * @param size
     * @param indexItemRelative
     * @return
     */
    @PostMapping("/getIndexNoRelativeArtworkPage")
    public Result getNoRelativeArtworkPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexItemRelative indexItemRelative) {
        IPage<Artwork> indexItemRelativeIPage = indexItemRelativeService.getNoRelativeArtworkPage(currentPage, size, indexItemRelative);
        return Result.success(indexItemRelativeIPage);
    }

    @PostMapping("/getIndexRelativeArtworkPage")
    public Result getIndexRelativeArtworkPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexItemRelative indexItemRelative) {
        IPage<Artwork> indexItemRelativeIPage = indexItemRelativeService.getIndexRelativeArtworkPage(currentPage, size, indexItemRelative);
        return Result.success(indexItemRelativeIPage);
    }

    @PostMapping("/saveSort")
    public Result saveSort(@RequestBody List<IndexItemRelative> indexItemRelativeList){
        indexItemRelativeService.saveSort(indexItemRelativeList);
        return Result.success("ok");
    }

    /**
     * 获取未关联的活动展览分页
     * @param currentPage
     * @param size
     * @param indexItemRelative
     * @return
     */
    @PostMapping("/getIndexNoRelativeEventExhibitionPage")
    public Result getNoRelativeEventExhibitionPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexItemRelative indexItemRelative) {
        IPage<EventExhibition> indexItemRelativeIPage = indexItemRelativeService.getNoRelativeEventExhibitionPage(currentPage, size, indexItemRelative);
        return Result.success(indexItemRelativeIPage);
    }


    /**
     * 获取已关联的活动展览分页
     * @param currentPage
     * @param size
     * @param indexItemRelative
     * @return
     */
    @PostMapping("/getIndexRelativeEventExhibitionPage")
    public Result getIndexRelativeEventExhibitionPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody IndexItemRelative indexItemRelative) {
        IPage<EventExhibition> indexItemRelativeIPage = indexItemRelativeService.getIndexRelativeEventExhibitionPage(currentPage, size, indexItemRelative);
        return Result.success(indexItemRelativeIPage);
    }



}
